package utils

import (
	"github.com/emicklei/go-restful/v3"
)

type Validatable interface {
	Validate() error
}

func ReadValidatableEntity(request *restful.Request, entity Validatable) error {
	err := request.ReadEntity(entity)
	if err != nil {
		return err
	}
	return entity.Validate()
}
